<template>
	<view :class="[primarySize()]">
		<view class="container plr30 bg-white">
			<view class="fs32 col3 tit_con">已屏蔽公司（共{{blacklist.length}}个）</view>
			<view class="business_info flex-box" v-for="(item,index) in blacklist">
				<view class="flex-grow-1">{{item.company_name}}</view>
				<image @click="bindRemoveBlacklist(index)" src="https://admin.mosizp.cn/static/public/close_img.png"
					mode="aspectFit"></image>
			</view>
			<button @click="bindAddBlacklist" hover-class="none" class="more_btn mt30">添加屏蔽公司</button>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				
				blacklist: [],
			}
		},
		onReady() {
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: this.primaryColor()
			})
		},
		onLoad: function(options) {
			let page = this;
			this.$core.get({
				url: 'xilujob.company/company_blacklist',
				success: ret => {
					this.blacklist= ret.data
				}
			});
		},
		methods: {
			bindAddBlacklist() {
				if (this.blacklist.length >= 5) {
					uni.showToast({
						title: '最多添加5个'
					});
					return;
				}
				uni.navigateTo({
					url: '/pages/public/search_privacy',
					events: {
						dataTransfer: data => {
							let addedList = data.addedList;
							this.blacklist= this.blacklist.concat(addedList)
						}
					}
				})
			},
			bindRemoveBlacklist(i) {
				let index = i,
					companyId = this.blacklist[index].id;
				this.$core.post({
					url: 'xilujob.company/set_blacklist_company',
					data: {
						company_ids: [companyId]
					},
					success: ret => {
						this.blacklist.splice(index, 1);
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tit_con {
		line-height: 109rpx;
	}

	.business_info {
		font-size: 30rpx;
		color: #333;
		padding: 30rpx 0;
		border-bottom: 1rpx solid #ebebeb
	}

	.business_info image {
		width: 22rpx;
		height: 22rpx;
		display: block
	}
</style>